package com.ukao.steward.ui.valetRunners.sendLetter;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.ukao.steward.R;
import com.ukao.steward.adapter.MyFragmentAdapter;
import com.ukao.steward.base.BaseFragment;
import com.ukao.steward.widget.QMUITabSegment;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 物流人员  送件
 */
public class SendLetterTabFragment extends BaseFragment {

    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";
    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.tabSegment)
    QMUITabSegment mTabSegment;
    @BindView(R.id.view_pager)
    ViewPager viewPager;


    private String mParam1;
    private String mParam2;

    private ArrayList<Fragment> mFragmentData;
    private Unbinder unbinder;

    public static SendLetterTabFragment newInstance(String param1, String param2) {
        SendLetterTabFragment fragment = new SendLetterTabFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_send_letter_tab, container, false);
        unbinder = ButterKnife.bind(this, view);
        initView();
        initListener();
        return view;
    }



    @Override
    protected void initView() {
        mFragmentData = new ArrayList<>();
        mTabSegment.setDefaultSelectedColor(resources.getColor(R.color.blue));
        mFragmentData.add(DontTakeFragment.newInstance(1));
        mFragmentData.add(DontTakeFragment.newInstance(2));
        mTabSegment.addTab(new QMUITabSegment.Tab("未取"));
        mTabSegment.addTab(new QMUITabSegment.Tab("未送"));
        MyFragmentAdapter mMyFragmentAdapter = new MyFragmentAdapter(getChildFragmentManager(), mFragmentData);
        viewPager.setAdapter(mMyFragmentAdapter);
    }


    @Override
    protected void initListener() {
        super.initListener();

    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;

        }
    }
}
